/**
 * User domain class.
 */
class Usuario {
    static transients = ['pass', 'email2']
    static hasMany = [authorities: Permissao , inscricao : Inscricao]
    /** Username */
    String username
    /** User Real Name*/
    String userRealName
    /** MD5 Password */
    String passwd
    /** enabled */
    boolean enabled = true
    String email
    boolean emailShow
    /** description */
    String description = ''
    /** plain password to create a MD5 password */
    String pass
    String email2 ;
    String keyPass;
    public Usuario(){
    }
    public Usuario(String username,
        String userRealName,
        String passwd,
        String pass,
        String email,
        String email2,
        String keyPass
      
    ){ 
        this.username = username
        this.userRealName = userRealName
        this.passwd = passwd
        this.pass = pass
        this.email = email
        this.email2 = email2
        this.keyPass = keyPass
    }

    String toString(){
        "${this.userRealName}"
    }


    static constraints = {
        username(blank: false, unique: true)
        userRealName(blank: false)
        passwd( blank:false, validator: {
                val, obj ->
                obj.properties['pass'] == val
            })


        enabled()
        email( blank:false, email:true, validator: {
                val, obj ->
                obj.properties['email2'] == val
            })

     
    }

    static mapping = {
        table "TB_USUARIO"
     //   id generator: 'sequence' ,params:[sequence:'tb_usuario_id_seq']
        version false
        username column : "DS_LOGIN"
        userRealName column : "DS_NOME"
        passwd column : "DS_SENHA"
        enabled column : "TP_ATIVO"
        email column : "DS_EMAIL"
        emailShow column : "TP_MOSTRAR_EMAIL"
        description column : "DS_DESCRICAO"
        pass column : "DS_PASS"
        email2 column : "DS_EMAIL2"
    }







}
